﻿@using eLoan.Models;
@model LoanCoMakerModel

@{
    ViewBag.Title = "Add/Edit Loan Co-Maker";

    var command = Model.DBCommand;
    var documentNo = Model.DocumentNo;
    var afterSave = command + "," + documentNo;
}

<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>Add/Edit Loan Co-Maker</h2>
        <ol class="breadcrumb">
            <li>
                Funding
            </li>
            <li>
                <a href="@Url.Action("Loans", "Funding")">Loans</a>
            </li>
            <li>
                <a href="@Url.Action("LoanCoMakersAndCollaterals", "Loan", new { documentNo = documentNo, borrowerID = Model.BorrowerID, branchCode = Model.BranchCode })">Loan Co-makers and Collaterals</a>
            </li>
            <li class="active">
                <strong>Add/Edit Loan Co-Maker</strong>
            </li>
        </ol>
    </div>
    <div class="col-lg-2"></div>
</div>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-8">
            <div class="ibox float-e-margins">
@using (Html.BeginForm("Save", "LoanCoMaker", FormMethod.Post, new { id = "saveForm" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    
    @Html.HiddenFor(m => Model.BorrowerID)
    @Html.HiddenFor(m => Model.BorrowerName)
    @Html.HiddenFor(m => Model.DocumentNo)
    @Html.HiddenFor(m => Model.BranchCode)
    @Html.HiddenFor(m => Model.DBCommand)

                <fieldset>
                    <div class="ibox-title">
                        <div>@Html.ValidationMessageFor(m => m.LoanCoMaker.CoMakerName)</div>
                        <div>@Html.ValidationMessageFor(m => m.LoanCoMaker.Address)</div>
                        <div>@Html.ValidationMessageFor(m => m.LoanCoMaker.ContactNumbers)</div>
                        <div>@Html.ValidationMessageFor(m => m.LoanCoMaker.IDNo)</div>
                    </div>
                    <div class="ibox-content">
                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Borrower</th>
                                    <th>Document No</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>@Html.ActionLink(Model.BorrowerName, "BorrowerDetails", "Borrower", null, null, null, new { borrowerID = Model.BorrowerName, branchCode = Model.BranchCode }, null)</td>
                                    <td>@Html.ActionLink(Model.DocumentNo, "LoanDetails", "Loan", null, null, null, new { documentNo = Model.DocumentNo }, null)</td>
                                </tr>
                            </tbody>
                        </table>
                        <table class="table table-bordered table-striped">
                            <tr>
                                <td>
                                    @if (command == "Edit")
                                    { @Html.HiddenFor(m => m.LoanCoMaker.ID) }
                                    @Html.HiddenFor(m => m.LoanCoMaker.DocumentNo)
                                    @Html.LabelFor(m => m.LoanCoMaker.CoMakerName)
                                </td>
                                <td>@Html.EditorFor(m => m.LoanCoMaker.CoMakerName)</td>
                                
                            </tr>
                            <tr>
                                <td>@Html.LabelFor(m => m.LoanCoMaker.Address)</td>
                                <td>@Html.EditorFor(m => m.LoanCoMaker.Address)</td>
                                
                            </tr>
                            <tr>
                                <td>@Html.LabelFor(m => m.LoanCoMaker.ContactNumbers)</td>
                                <td>@Html.EditorFor(m => m.LoanCoMaker.ContactNumbers)</td>
                                
                            </tr>
                            <tr>
                                <td>@Html.LabelFor(m => m.LoanCoMaker.IDNo)</td>
                                <td>@Html.EditorFor(m => m.LoanCoMaker.IDNo)</td>
                                
                            </tr>
                        </table>

                        <p></p>

                        <button type="submit" id="btnSave" class="btn btn-primary" name="afterSave" value=@afterSave>Save</button>
                        <button type="submit" id="btnCancel" class="btn btn-primary cancel" name="afterSave" value="Cancel,@documentNo">Cancel</button>
                    </div>
                </fieldset>
}
            </div>

        </div>
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}


